package com.ayoka.mvp;

import com.ayoka.R;
import com.ayoka.base.BasePresenter;
import com.ayoka.base.IBaseView;
import com.ayoka.bean.BaseResponse;
import com.ayoka.bean.CourseBean;
import com.ayoka.bean.PagerBean;
import com.ayoka.http.API;
import com.ayoka.http.OkHttpListener;
import com.jcp.baselibrary.utils.UIUtils;

/**
 * Created by gabriel on 2017/3/5.
 */

public interface CollectionMVP {

    interface CollectionModel {

    }

    interface ICollectionView extends IBaseView {

        void configCollectionListData(PagerBean pagerBean);

    }

    class CollectionPresenter extends BasePresenter<ICollectionView> {

        public void getCourseCollectionListData(boolean isShowWaitDialog, int pageNo, int pageSize) {
            if (isShowWaitDialog) {
                mViewRef.get().showWaitDialog(UIUtils.getString(R.string.loading));
            }
            API.getCourseCollectionListData(this, pageNo, pageSize, new OkHttpListener<BaseResponse<PagerBean<CourseBean>>>() {
                @Override
                public void onSuccess(BaseResponse<PagerBean<CourseBean>> response) {
                    if (!isAttached()) return;
                    mViewRef.get().hideWaitDialog();
                    mViewRef.get().configCollectionListData(response.data);
                }

                @Override
                public void onFailure(int errorCode, String errorMessage) {
                    if (!isAttached()) return;
                    mViewRef.get().hideWaitDialog();
                    mViewRef.get().showToast(errorMessage);
                }
            });
        }

        public void getMeditationCollectionListData(boolean isShowWaitDialog, int pageNo, int pageSize) {
            mViewRef.get().configCollectionListData(null);
        }

    }

}
